package org.terrier.matching.models.basicmodel;

import org.terrier.utility.ApplicationSetup;

import uk.ac.gla.terrier.statistics.HKGammaFunction;

public class CScdf extends BasicModel {
	/*
     * chi-square cdf 
     */
    protected double n = Double.parseDouble(ApplicationSetup.getProperty(
    		"distribution.parameter.0", "0.6"));;//the freedom degree

	@Override
	public String getInfo() {
		return "CScdf";
	}

	@Override
	public double score(double tf, double documentFrequency,
			double termFrequency, double keyFrequency, double documentLength) {
		/*
		 * exponential
		 */	
		return (1- Math.exp(-(tf / 2)) / (Math.pow(2, (n / 2)) * HKGammaFunction.getValue(n / 2)))*keyFrequency;
	}
	
	public void initModel(){
		String value = null;
		if ((value = ApplicationSetup.getProperty("distribution.parameter.0", "0.6d"))!=null){
			this.n = Double.parseDouble(value);
		}
	}

}
